#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Mon Jul  2 09:43:29 2018

@author: chenliheng
"""
  
#1 装饰器函数，包含函数类型的参数
def w1(fun1):
    #2 声明内部函数，执行补充的装饰代码
    def inner():
        print('日志输出:函数调用前……')
        fun1()
        print('函数调用结束后……')
    return inner

from time import time
def w2(fun):
    def inner():
        begin = time()
        fun()
        end = time()
        print(end - begin)
    return inner

# 独立函数
# 函数附加装饰器(python3特有)
@w1
def f1():
    print("f1")
    
@w1
@w2
def f2():
    for i in range(1000):
        print(i)
    

f2()
"""
import time

begin = time.time()

for i in range(1000):
    print(i)
    
end = time.time()

print('执行100000次循环花费的时间:' + str(end - begin))
"""
"""
from timeit import timeit
t = timeit('[i for i in range(100) if i%2==0]', number=10000)

print(t)
"""